package thread.assignment.url;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class HttpURLConnection_thread {
	public static void main(String[] args) {
		final String dir = System.getProperty("user.dir");
		URL url = null;

		try {
			url = new File(dir + "/bin/thread/assignment/url/table.html").toURI().toURL();
			
			long startTime = System.nanoTime();
			
			for (int i=1; i <=10; i++) {
				URLRunnable runnable = new URLRunnable(url);
				//new Thread(runnable).start();
				URLExecutor exe = new URLExecutor();
				exe.execute(runnable);
			}
			
			long elapsedTime = System.nanoTime() - startTime;
			System.out.println("Time taken : " + TimeUnit.SECONDS.convert(elapsedTime, TimeUnit.NANOSECONDS) + " Seconds");
			
		} catch (MalformedURLException ex) {
			ex.printStackTrace();
		}
		
		
	}
	
}
